package threading;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lishuo
 * Date: 2023-03-25
 * Time: 20:42
 */
class MyRunnable implements Runnable {

    @Override
    public void run() {
        while (true) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("hello t");
        }
    }
}

public class ThreadDemo2 {
    //这种方式是使用Runnable interface来描述线程入口
    public static void main(String[] args) throws InterruptedException {
        MyRunnable runnable = new MyRunnable();
        Thread t = new Thread(runnable);
        t.start();

        while (true) {
            Thread.sleep(1000);
            System.out.println("hello main");
        }
    }
}
